﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace ElectronicCommerce.Framework.Web.Mvc.WebForm
{
    public class CustomViewUserControlBase : UserControl
    {
        protected virtual void RenderPage()
        {
            //Rendering Page
        }
    }

    public class CustomViewUserControlBase<TCustomViewPage, TCustomContext, TModel> : CustomViewUserControlBase
        where TCustomViewPage : CustomViewPageBase<TCustomContext>
        where TCustomContext : CustomContextBase
        where TModel : CustomModelBase
    {

        private CustomModelContainer<TCustomContext, TModel> _model = null;

        public CustomModelContainer<TCustomContext, TModel> Model
        {
            get
            {
                if (_model == null)
                {
                    _model = new CustomModelContainer<TCustomContext, TModel>(ViewPage.CustomContext, ViewPage.Model.ModelDictionary);
                }
                return _model;
            }
        }

        public TCustomViewPage ViewPage
        {
            get
            {
                return Page as TCustomViewPage;
            }
        }
    }
}
